package com.mbigger.admin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mbigger.admin.dto.AclModuleLevelDto;
import com.mbigger.admin.param.AclModuleParam;
import com.mbigger.admin.service.AclModuleService;
import com.mbigger.admin.service.TreeService;

import java.util.List;

@RestController
@RequestMapping("/sys/aclModule")
public class AclModuleController {

	@Autowired
	private AclModuleService aclModuleService;
	@Autowired
	private TreeService treeService;

	@PostMapping("/save")
	public void saveAclModule(AclModuleParam param) {
		aclModuleService.save(param);
	}

	@PostMapping("/update")
	public void updateAclModule(AclModuleParam param) {
		aclModuleService.update(param);
	}

	@GetMapping("/tree")
	public List<AclModuleLevelDto> tree() {
		return treeService.aclModuleTree();
	}

	@DeleteMapping("/delete")
	public void delete(int id) {
		aclModuleService.delete(id);
	}
}
